﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversalTools;

namespace Calculator
{
    static class Application
    {
        public static void Main(string[] args)
        {
            ExpressionParser parser = null;
            var calc = new Calculator();
            if (calc.IsNotNullOrEmpty())
                parser = new ExpressionParser();
            Start:
            var expression = Console.ReadLine();

            if (!calc.IsValidExpression(expression))
            {
                Console.WriteLine("Invalid Expression. Try again");
                expression = Console.ReadLine();
            }
            var operands = parser.GetOperands(expression);
            Console.WriteLine(calc.Calculate(operands.Item1,operands.Item2,parser.GetOperation(expression)));
            Console.WriteLine();
            goto Start;
        }
    }
}
